home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / NeoIntroPP3.0 folder / PowerPlant / Laughs / Source / CPerson.cp < prev   
Encoding:
Text File  |  1994-02-23  |  2.1 KB  |  124 lines  |  [TEXT/MMCC]

  1. /*     Program name: CPerson  (body)
  2.     Author        : Paul Gee
  3.     Version        : 0.1
  4.     Date        : 19th February 1993
  5.     Purpose        : 
  6. */
  7.  
  8. #include "NeoTypes.h"
  9. #include CNeoStreamH
  10. #include <string.h>
  11. #include <stdio.h>
  12. #include "CPerson.h"
  13.  
  14. CPerson::CPerson(char *aName, NeoID aID)
  15. {
  16.     strncpy(fName, aName, sizeof(fName) -1);
  17.     setID(aID);
  18. }
  19.  
  20. #pragma segment NeoRead
  21. void CPerson::readObject(CNeoStream *aStream, const NeoTag aTag)
  22. {
  23.     inherited::readObject(aStream, aTag);
  24.  
  25.     aStream->readString(fName, sizeof(fName));
  26. }
  27.  
  28. #pragma segment NeoWrite
  29. void CPerson::writeObject(CNeoStream *aStream, const NeoTag aTag)
  30. {
  31.     inherited::writeObject(aStream, aTag);
  32.  
  33.     aStream->writeString(fName, sizeof(fName));
  34. }
  35.  
  36. void CPerson::printName(void) const
  37. {
  38.     printf("Name is %s\n", fName);
  39. }
  40.  
  41. CJoker::CJoker(char *aName, NeoID aID)
  42.     : CPerson(aName, aID)
  43. {
  44.     setJoke("My dogs got no nose?");
  45. }
  46.  
  47. CNeoPersist *CJoker::New(void)
  48. {
  49.     return new CJoker;
  50. }
  51.  
  52. NeoID CJoker::getClassID(void) const
  53. {
  54.     return kJokerID;
  55. }
  56.  
  57. long CJoker::getFileLength(void) const
  58. {
  59.     return kJokerFileLength;
  60. }
  61.  
  62. #pragma segment NeoRead
  63. void CJoker::readObject(CNeoStream *aStream, const NeoTag aTag)
  64. {
  65.     inherited::readObject(aStream, aTag);
  66.  
  67.     aStream->readString(fJoke, sizeof(fJoke));
  68. }
  69.  
  70. #pragma segment NeoWrite
  71. void CJoker::writeObject(CNeoStream *aStream, const NeoTag aTag)
  72. {
  73.     inherited::writeObject(aStream, aTag);
  74.  
  75.     aStream->writeString(fJoke, sizeof(fJoke));
  76. }
  77.  
  78. void CJoker::skill(void) const
  79. {
  80.     printf("Tells jokes : %s\n", fJoke);
  81. }
  82.  
  83. CClown::CClown(char *aName, NeoID aID)
  84.     : CPerson(aName, aID)
  85. {
  86.     setPieType("Custard");
  87. }
  88.  
  89. CNeoPersist *CClown::New(void)
  90. {    
  91.     return new CClown;
  92. }
  93.  
  94. NeoID CClown::getClassID(void) const
  95. {
  96.     return kClownID;
  97. }
  98.  
  99. long CClown::getFileLength(void) const
  100. {
  101.     return kClownFileLength;
  102. }
  103.  
  104. #pragma segment NeoRead
  105. void CClown::readObject(CNeoStream *aStream, const NeoTag aTag)
  106. {
  107.     inherited::readObject(aStream, aTag);
  108.  
  109.     aStream->readString(fPieType, sizeof(fPieType));
  110. }
  111.  
  112. #pragma segment NeoWrite
  113. void CClown::writeObject(CNeoStream *aStream, const NeoTag aTag)
  114. {
  115.     inherited::writeObject(aStream, aTag);
  116.  
  117.     aStream->writeString(fPieType, sizeof(fPieType));
  118. }
  119.  
  120. void CClown::skill(void) const
  121. {
  122.     printf("Throws %s pies\n", fPieType);
  123. }
  124.